package com.genesis.yunnanji;

import java.util.ArrayList;
import java.util.List;

import com.genesis.yunnanji.activity.BaseActivity;
import com.genesis.yunnanji.adapter.FragmentAdapter;
import com.genesis.yunnanji.fragment.WelcomeFragment;
import com.genesis.yunnanji.utils.GenesisUtils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;

public class WelcomeActivity extends BaseActivity implements
        OnClickListener {

    private Context context = this;
    private GenesisUtils fcUtils = GenesisUtils.getIntance();
    private FragmentManager fragmentManager = getSupportFragmentManager();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState, R.layout.activity_welcomoe);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ib_welcome_close:
                startActivity(new Intent(context, MainActivity.class));
                finish();
                break;
        }
    }

    ViewPager vp;
    Button ib_close;



    List<Fragment> fragments;

    FragmentAdapter adapter;

    @Override
    protected void initView(Bundle savedInstanceState) {
        vp = (ViewPager) findViewById(R.id.vp_welcome);
        ib_close = (Button) findViewById(R.id.ib_welcome_close);
        ib_close.setOnClickListener(this);
        fcUtils.init(context);
        setUpView();
    }

    protected void setUpView() {
        fcUtils.setIsFirst(false);
        ib_close.setOnClickListener(this);
        fragments = new ArrayList<Fragment>();
        fragments.add(WelcomeFragment.newInstance(1));
        fragments.add(WelcomeFragment.newInstance(2));
        fragments.add(WelcomeFragment.newInstance(3));
        adapter = new FragmentAdapter(fragmentManager, fragments);
        vp.setAdapter(adapter);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        return false;
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
    }
}
